<template>
  <div class="EquipmentselectionList">
    <NavBar
      fixed
      placeholder
      title="设备选择"
      z-index="999"
      @click-right="onClickRight"
      ref="nav"
    >
      <template #left>
        <Icon
          name="arrow-left"
          size="0.53rem"
          color="#333333"
          @click="$router.back()"
        />
      </template>
    </NavBar>
    <Search
      v-model="search"
      background="#e1e1e1"
      placeholder="请输入搜索关键词"
      show-action
      @search="onSearch"
      @cancel="onCancel"
    />

    <List
      v-model="loading"
      :finished="finished"
      finished-text="没有更多了"
      @load="onLoad"
    >
      <div
        class="item"
        v-for="(item, i) in list"
        :key="i"
        @click="toJump(item)"
      >
        <div class="row">
          <div class="title flex">
            <div class="placeholder"></div>
            {{ item.name }}
          </div>
          <div class="state">{{ item.state }}</div>
        </div>
        <div class="row row1">
          <Icon class="icon" name="home-o"></Icon>
          <div class="type">设备类型：{{ item.categoryName }}</div>
        </div>
        <div class="row row1">
          <Icon class="icon" name="location-o"></Icon>
          <div class="type">{{ item.address }}</div>
        </div>
      </div>
    </List>
  </div>
</template>

<script>
import { EquipmentSelectionList } from "../../../api/work.js";
import { Search, NavBar, Icon, List, Cell } from "vant";
export default {
  props: {},
  data() {
    return {
      search: "",
      list: [],
      loading: false,
      finished: false,
      pageNum: 1,
      pageSize: 10,
    };
  },

  created() {},
  mounted() {},
  watch: {},
  methods: {
    async onLoad() {
      const { param } = await EquipmentSelectionList({
        orgNo: localStorage.getItem("orgNo"),
        equipName: this.search,
        pageNum: this.pageNum,
        pageSize: this.pageSize,
      });
      console.log("data", param);
      this.list.push(...param.data);
      this.loading = false;
      if (this.list.length < this.pageSize * this.pageNum) {
        this.finished = true;
      }
      this.pageNum++;
    },
    onClickRight() {},
    onSearch() {},
    onCancel() {},
    toJump(item) {
      // return console.log(item);
      this.$router.push({
        path: "equipmentRepair",
        query: {
          id: item.id,
          name: item.name,
          address: item.address,
        },
      });
    },
  },
  components: { Search, NavBar, Icon, List, Cell },
};
</script>

<style scoped lang="less">
@import "~@/style/var.less";
.EquipmentselectionList {
  .flex {
    display: flex;
    justify-content: center;
    align-items: center;
  }
  background-color: #f7f7f9;
  // /deep/.van-nav-bar__content {
  //   background-color: #3982f6;

  //   .van-nav-bar__title {
  //     color: #fff;
  //   }
  // }
  .item {
    border-top: 1px solid #eee;
    margin-top: 20px;
    background-color: #fff;
    .row {
      display: flex;
      align-items: center;
      justify-content: space-between;
      height: 72px;
      border-bottom: 1px solid #eee;

      .title {
        font-size: 32px;
        font-weight: 700;
        .placeholder {
          width: 5px;
          height: 30px;
          background: @primary-linear;
          margin: 0 20px;
        }
      }
      .state {
        margin-right: 20px;
        width: 132px;
        height: 44px;
        // background-color: #fff4e7;
        border-radius: 22px;
        display: flex;
        justify-content: center;
        align-items: center;
        font-size: 28px;
        color: @primary;
      }
    }
    .row1 {
      justify-content: start;
      font-size: 28px;
      color: #999999;
      .icon {
        margin: 0 20px;
        font-size: 35px;
      }
    }
  }
}
</style>
